package com.school.manager.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.school.manager.common.Constants;
import com.school.manager.entity.po.SysUserPo;

public class MyContextHolder {
	
	private MyContextHolder() {}
	
	
	/**
	 * 获取当前登录用户
	 * @return
	 */
	public static SysUserPo getCurrentUser() {
		ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
		HttpServletRequest request = attributes.getRequest();
		HttpSession session = request.getSession();
		return (SysUserPo) session.getAttribute(Constants.CURRENT_USER);
	}

}
